@extends('layouts.admin')

@section('content')
<div class="page-content">

	<div class="row">

		<div class="col-xs-12">

			<h3 class="header smaller lighter blue">学生信息
				<span class="span5">
				<label class="inline">只查看未选导师学生:</label>
				<label class="inline">
					<input id="id-button-borders" @if($onlyUnselectedStudents == 1) checked="checked" @endif type="checkbox" class="ace ace-switch ace-switch-5">
					<span class="lbl"></span>
				</label>
			</span></h3>
			<div class="table-responsive">

				<table id="sample-table-2" class="table table-striped table-bordered table-hover">
					<thead>
						<tr>
							<th>学生姓名</th>
							<th>班级</th>
							<th class="hidden-480">专业</th>
							<th>手机</th>
							<th>邮箱</th>
							<th>指导老师</th>
						</tr>
					</thead>
					<tbody>
						@if($onlyUnselectedStudents == 1) 
						@foreach($students as $student)
						<tr>
							<td>
								<a href="#">{{$student->user->name}}</a>
							</td>
							<td>{{$student->class}}</td>
							<td class="hidden-480">{{$student->major}}</td>
							<td>
								{{$student->user->phone}}
							</td>
							<td>
								{{$student->user->email}}
							</td>
							<td>
								无
							</td>
						</tr>
						@endforeach
						@else
						@foreach($users as $user)
						<tr>
							<td>
								<a href="#">{{$user->name}}</a>
							</td>
							<td>{{$user->student->class}}</td>
							<td class="hidden-480">{{$user->student->major}}</td>
							<td>
								{{$user->phone}}
							</td>
							<td>
								{{$user->email}}
							</td>
							<td>
								@if($user->student->supervisors()->wherePivot('isApproved', true)->count() > 0)
								{{$user->student->supervisors()->wherePivot('isApproved', true)->first()->user->name}}
								@else
								无
								@endif
							</td>
						</tr>
						@endforeach
						@endif
					</tbody>

				</table>
				@if($onlyUnselectedStudents == 1)  {{ $students->links() }} @else {{ $users->links() }}  @endif
			</div>
			<div class="row">
				<div class="form-actions center delegate-list">
					<hr id="split-line">
					<button type="button" class="btn btn-sm btn-success center" onclick="export_data();">
						导出
						<i class="icon-arrow-right  bigger-110" ></i>
					</button>
				</div>
			</div>
		</div>

	</div>

</div>
<script type="text/javascript">
	jQuery(function($) {
		$('#id-button-borders').on('click', function(){
			if({{$onlyUnselectedStudents}}) {
				window.location.href = "/admin/twowaychoice/0";
			} else {
				window.location.href = "/admin/twowaychoice/1";
			}
		});
	})

	function export_data() {
		window.location.href = "/admin/export/twowaychoice";
	}
</script>
@endsection
